package bungaeting.net.client.android.activity;

import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import bungaeting.net.client.android.R;
import bungaeting.net.client.android.request.RequestObserver;
import bungaeting.net.client.android.task.BackgroundService;
import bungaeting.net.client.android.utils.JsonUtil;

public class TestActivity extends Activity {
	BackgroundService backgroundService = new BackgroundService();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		backgroundService.startWorkerThread();
		
		setContentView(R.layout.main);
		
		
		Button buttonTest1 = (Button)findViewById(R.id.buttonTest1);
		if (buttonTest1 != null){
			buttonTest1.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					test1();
				}
			});
		}
		
	}
	
	protected void test1(){
		Map<String, Object> map = JsonUtil.toMap("{'serviceId':'service1', 'requestId':'request1', 'params':{'param1':'value1', 'param2':'value2', 'list1':[1,2,3,4], 'list2':[{'ep1':'value1', 'ep2':'value2'}, {'ep1':'value3', 'ep2':'value4'}]}}");
//		Log.d("TEST", map.toString());
//		Log.d("TEST", JsonUtil.toJSonString(map));

		backgroundService.requestAsync("createMeeting", "", map, new RequestObserver(RequestObserver.THREAD_TYPE.UI_THREAD){
			@Override
			public void update(String requestId, String returnCode, String returnMsg, Object params) {
				// TODO Auto-generated method stub
				Log.d("TEST", "update complate()");
				Log.d("TEST", "requestId " + requestId);
				Log.d("TEST", "returnCode " + returnCode);
				Log.d("TEST", "returnMsg " + returnMsg);
				Log.d("TEST", "params " + params);
			}
		});
	}
}
